package com.wiki.gds.user.provider.modular;


import com.wiki.gds.base.security.common.model.SecurityUser;
import com.wiki.gds.member.facade.member.api.MemberApi;
import com.wiki.gds.member.facade.member.model.Member;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("ttt")
public class memberController {

    @Autowired
    private MemberApi memberApi;

    @RequestMapping("/test1")
    public String test(){
        Object user=SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        SecurityUser securityUser=new SecurityUser();

        BeanUtils.copyProperties(user,securityUser);
//        securityUser.setPassWord(user.getPassword());
//        securityUser.setUserName(user.getUsername());
//        securityUser.setGrantList(user.getAuthorities());
        System.out.print(securityUser);

        return "asdasd";
    }

    @RequestMapping("test2")
    private Member test2(){
        Member member=new Member();
        member.setUsername("admin");
        String aa=memberApi.Test();
       member= memberApi.getMemberBySelf(member);
       return member;
    }

}
